﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace App21 {
  class Program {
    static void Main(string[] args) {
      test1();
    }

    private int Foo(int x) {
      return x * 10; 

    }

    private static void test1() {
      Type t;
      t = typeof(Program);

      Console.WriteLine(t.Name);
      Console.WriteLine(t.FullName +"test ");
      Console.WriteLine(t.Namespace);
    

      Console.WriteLine("Methods : ");
      foreach (var mi in t.GetMethods()) {
        Console.WriteLine("    {0}", mi);
      }

      var obj = new Program();
      var foo = t.GetMethod("Foo", BindingFlags.NonPublic | BindingFlags.Instance);
      var result = foo.Invoke(obj, new object[] { 5 });
      Console.WriteLine(result);

      Console.WriteLine("Members : ");
      foreach (var m in t.GetMembers(BindingFlags.Public
      | BindingFlags.NonPublic
      | BindingFlags.Static
      | BindingFlags.Instance)) {
        Console.WriteLine(string.Format("{0} : {1}", m.MemberType, m.Name));
      }
    }
  }
}
